package com.tucy.logistics.modules.vehicle.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tucy.logistics.common.entity.vehicle.VehicleType;
import com.tucy.logistics.common.result.Result;
import com.tucy.logistics.modules.vehicle.service.VehicleTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/10/12
 * description:
 */
@Api(tags = "车辆类型")
@RestController
@RequestMapping("/vehicleType")
public class VehicleTypeController {

    @Autowired
    VehicleTypeService vehicleTypeService;

    @ApiOperation(value = "查询车辆类型")
    @GetMapping("/queryVehicleTypes")
    public Result<List<VehicleType>> queryVehicleTypes() {
        return Result.success(vehicleTypeService.queryVehicleTypes());
    }

    @ApiOperation(value = "增改车辆类型")
    @PostMapping("/saveUpdateVehicleTypes")
    public Result<Boolean> saveUpdateVehicleTypes(@RequestBody VehicleType vehicleType) {
        return Result.success(vehicleTypeService.saveOrUpdate(vehicleType));
    }

    @ApiOperation(value = "车辆类型详情")
    @GetMapping("/vehicleTypesDetails/{id}")
    public Result<VehicleType> vehicleTypesDetails(@PathVariable("id") String id) {
        return Result.success(vehicleTypeService.getBaseMapper().selectById(id));
    }

    @ApiOperation(value = "删除车辆类型")
    @GetMapping("/DeleteVehicleTypes/{id}")
    public Result<Boolean> DeleteVehicleTypes(@PathVariable("id") String id) {
        return Result.success(vehicleTypeService.getBaseMapper().deleteById(id) == 1);
    }
}
